package com.zhuliwei.rabbitmq.direct.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.zhuliwei.constants.RabbitConstants.*;

/**
 * Notice类型消息队列配置
 *
 * @author 朱力维
 * @time 2024/11/14 15:00
 **/
@Configuration
public class NoticeDirectConfig {
    @Bean
    public Queue queue() {
        return new Queue(NOTICE_QUEUE_NAME, true, false, false);
    }

    @Bean
    public Queue queue2() {
        return new Queue(NOTICE_QUEUE2_NAME, true, false, false);
    }

    @Bean
    public Queue queue3() {
        return new Queue(NOTICE_QUEUE3_NAME, true, false, false);
    }

    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(NOTICE_EXCHANGE_NAME);
    }

    @Bean
    public Binding BindingDirect(@Qualifier("queue") Queue queue, @Qualifier("exchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(NOTICE_ROUTING_KEY);
    }
    @Bean
    public Binding BindingDirect2(@Qualifier("queue2") Queue queue, @Qualifier("exchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(NOTICE_AUDIT_KEY);
    }

    @Bean
    public Binding BindingDirect3(@Qualifier("queue3") Queue queue, @Qualifier("exchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(NOTICE_ARTICLE_KEY);
    }
}
